Communications 103

I will say "Hello World" to the reader with an Alert box when he or she presses the button below.

Discussion

This third "hello" program uses an alert box to greet the reader. There are no JavaScript calls from the HTML body. Instead, a button's onClick event is used to trigger the call to our userAlert function. In JavaScript, users create events by moving the mouse over links, clicking buttons, activating or deactivating text fields, and so forth. Events provide a standard way to trigger JavaScript functionality.

The userAlert() function

function userAlert(){
alert("Hello World!")
}

The event call

<FORM>
<INPUT
TYPE="button"
VALUE=" Say Hello World to the Reader "
onClick="userAlert()"
>
</FORM>
Copyright ©1998 by Charles River Media, All Rights Reserved